from tools import all_flow_ILAE_1440, all_flow_ILAE_1441, all_flow_ILAE_1442, all_flow_ILAE_1443, all_flow_ILAE_1444, \
    all_flow_ILAE_1445, all_flow_ILAE_1446, all_flow_ILAE_1447, all_flow_ILAE_1448, all_flow_ILAE_1449, \
    all_flow_ILAE_1450, all_flow_ILAE_1451
from global_parameter import ip, port, username, DB_NAME

channel_2v0_scene1 = [
    "1, 6, 1, 1, '1', 5, '1', 2, '2023-08-07 15:46:15', NULL, '', 1, '','',''",
    "2, 6, 2, 100, '100', 5, '1', 2, '2023-08-07 15:46:24', NULL, '', 1, '','',''"]

addr_2v0_scene1 = [
    "1, 1, '000000001001'",
    "2, 100, '000000001100'"]

current_1A_sql_config = [
    "TRUNCATE au_board_information;",  # 板卡信息表
    "TRUNCATE au_channel_sort;",  # 采集板模拟量通道排序
    "TRUNCATE au_collect_board_config;",  # 采集板参数
    "TRUNCATE au_main_board_config;",  # 主控板参数
    "INSERT INTO `au_board_information` VALUES (3, 6, '电流采集板卡', '02', '02', 'CVT-CT-DSP_1.0.2', 'CVT-CT-DSP_1.2.8', '2023-08-07 15:45:58', '2023-08-07 15:45:58', 0, NULL, NULL, 1, '1');",
    "INSERT INTO `au_channel_sort` VALUES (1, '02', '02', 6, '1', 'A', '4001', 1, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (2, '02', '02', 6, '1', 'B', '4002', 2, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (3, '02', '02', 6, '1', 'C', '4003', 3, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (4, '02', '02', 6, '2', 'A', '4011', 4, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (5, '02', '02', 6, '2', 'B', '4012', 5, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (6, '02', '02', 6, '2', 'C', '4013', 6, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (7, '02', '02', 6, '3', 'A', '4021', 7, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (8, '02', '02', 6, '3', 'B', '4022', 8, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (9, '02', '02', 6, '3', 'C', '4023', 9, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (10, '02', '02', 6, '4', 'A', '4031', 10, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (11, '02', '02', 6, '4', 'B', '4032', 11, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (12, '02', '02', 6, '4', 'C', '4033', 12, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (13, '02', '02', 6, '5', 'A', '4041', 13, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (14, '02', '02', 6, '5', 'B', '4042', 14, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (15, '02', '02', 6, '5', 'C', '4043', 15, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_collect_board_config` VALUES (1, 1, '02', '02', 6, 16, 'CVT-CT-DSP_1.0.2', 16, 'CVT-CT-DSP_1.2.8', '', 8, '22092101', '2023-08-07 15:45:58', 1, '1', NULL, NULL);",
    "INSERT INTO `au_main_board_config` VALUES (1, '02', 7, '1.0.0.1', 5, '1.5.1', '', 8, '22120901', '2023-08-07 15:45:58', 1);"
]

current_5A_sql_config = [
    "TRUNCATE au_board_information;",
    "TRUNCATE au_channel_sort;",
    "TRUNCATE au_collect_board_config;",
    "TRUNCATE au_main_board_config;",
    "INSERT INTO `au_board_information` VALUES (3, 6, '电流采集板卡', '02', '02', 'CVT-CT-DSP_1.0.2', 'CVT-CT-DSP_1.2.8', '2023-08-07 15:45:58', '2023-08-07 15:45:58', 0, NULL, NULL, 1, '5');",
    "INSERT INTO `au_channel_sort` VALUES (1, '02', '02', 6, '1', 'A', '4001', 1, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (2, '02', '02', 6, '1', 'B', '4002', 2, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (3, '02', '02', 6, '1', 'C', '4003', 3, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (4, '02', '02', 6, '2', 'A', '4011', 4, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (5, '02', '02', 6, '2', 'B', '4012', 5, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (6, '02', '02', 6, '2', 'C', '4013', 6, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (7, '02', '02', 6, '3', 'A', '4021', 7, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (8, '02', '02', 6, '3', 'B', '4022', 8, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (9, '02', '02', 6, '3', 'C', '4023', 9, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (10, '02', '02', 6, '4', 'A', '4031', 10, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (11, '02', '02', 6, '4', 'B', '4032', 11, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (12, '02', '02', 6, '4', 'C', '4033', 12, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (13, '02', '02', 6, '5', 'A', '4041', 13, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (14, '02', '02', 6, '5', 'B', '4042', 14, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_channel_sort` VALUES (15, '02', '02', 6, '5', 'C', '4043', 15, '2023-08-07 15:45:59', 2, NULL, 1, NULL);",
    "INSERT INTO `au_collect_board_config` VALUES (1, 1, '02', '02', 6, 16, 'CVT-CT-DSP_1.0.2', 16, 'CVT-CT-DSP_1.2.8', '', 8, '22092101', '2023-08-07 15:45:58', 1, '5', NULL, NULL);",
    "INSERT INTO `au_main_board_config` VALUES (1, '02', 7, '1.0.0.1', 5, '1.5.1', '', 8, '22120901', '2023-08-07 15:45:58', 1);"
]

no_group_2v0 = [
    "1, 1, 5, 1",
    "1, 100, 5, 1"]

# 通用算法
algo_scene = [
    "4, '1', '1', '1,3', '0', '', '0', NULL, '2023-04-14 11:44:50', NULL, NULL, NULL, NULL, NULL, 7, 14, 7, 14, '0', '0', '1'"]

"""
330kV电压等级对应的字典键值(8)  330kV电压等级线路数  330kV电压等级同源标志(True  False)  330kV电压等级分列标志(True  False)  330kV电压等级停电标志(True  False) 
220kV电压等级对应的字典键值(5)  220kV电压等级线路数  220kV电压等级同源标志(True  False)  220kV电压等级分列标志(True  False)  220kV电压等级停电标志(True  False) 
110kV电压等级对应的字典键值(4)  110kV电压等级线路数  110kV电压等级同源标志(True  False)  110kV电压等级分列标志(True  False)  110kV电压等级停电标志(True  False) 
10kV 电压等级对应的字典键值(3)  10kV 电压等级线路数  10kV 电压等级同源标志(True  False)  10kV 电压等级分列标志(True  False)  10kV 电压等级停电标志(True  False) 
"""
v_arg_2v0_gao_bing = [8, 0, False, False, False,
                      5, 2, False, False, False,
                      4, 0, False, False, False,
                      3, 0, False, False, False]

# ILAE-1440 电流频率异常_频率调整触发&恢复_1A
all_flow_ILAE_1440(ip, DB_NAME, v_arg_2v0_gao_bing, "ILAE-1440", current_1A_sql_config, channel_2v0_scene1,
                   addr_2v0_scene1,
                   no_group_2v0, algo_scene, [150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150],
                   time_data=[-25, 80])

# ILAE-1441 电流频率异常_频率值调整触发&删除线路恢复_1A
# 已知删除线路恢复之后不会产生频率异常自诊断事件
all_flow_ILAE_1441(ip, DB_NAME, v_arg_2v0_gao_bing, "ILAE-1441", current_1A_sql_config, channel_2v0_scene1,
                   addr_2v0_scene1, no_group_2v0, algo_scene,
                   [150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150],
                   time_data=[-25, 60])
#
# # ILAE-1442 电流频率值异常_任意单相触发检查_1A
# all_flow_ILAE_1442(ip, DB_NAME, v_arg_2v0_gao_bing, "ILAE-1442", current_1A_sql_config, channel_2v0_scene1,
#                    addr_2v0_scene1,
#                    no_group_2v0, algo_scene, [150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150],
#                    time_data=[-25, 60])
#
# # ILAE-1443 电流频率异常_频率调整触发&恢复_5A
# all_flow_ILAE_1443(ip, DB_NAME, v_arg_2v0_gao_bing, "ILAE-1443", current_5A_sql_config, channel_2v0_scene1,
#                    addr_2v0_scene1,
#                    no_group_2v0, algo_scene, [150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150],
#                    time_data=[-25, 80])
#
# # ILAE-1444 电流频率异常_频率值调整触发&删除线路恢复_5A
# all_flow_ILAE_1444(ip, DB_NAME, v_arg_2v0_gao_bing, "ILAE-1444", current_5A_sql_config, channel_2v0_scene1,
#                    addr_2v0_scene1,
#                    no_group_2v0, algo_scene, [150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150],
#                    time_data=[-25, 60])
#
# # # ILAE-1445 电流频率值异常_任意单相触发检查_5A
# all_flow_ILAE_1445(ip, DB_NAME, v_arg_2v0_gao_bing, "ILAE-1445", current_5A_sql_config, channel_2v0_scene1,
#                    addr_2v0_scene1,
#                    no_group_2v0, algo_scene, [150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150],
#                    time_data=[-25, 60])
#
# # ILAE-1446 电流数据幅值异常_幅值调整触发&恢复_1A
# all_flow_ILAE_1446(ip, DB_NAME, v_arg_2v0_gao_bing, "ILAE-1446", current_1A_sql_config, channel_2v0_scene1,
#                    addr_2v0_scene1,
#                    no_group_2v0, algo_scene, [150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150],
#                    time_data=[-25, 80])
#
# # ILAE-1447 电流数据幅值异常_幅值调整触发&删除线路恢复_1A
# all_flow_ILAE_1447(ip, DB_NAME, v_arg_2v0_gao_bing, "ILAE-1447", current_1A_sql_config, channel_2v0_scene1,
#                    addr_2v0_scene1,
#                    no_group_2v0, algo_scene, [150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150],
#                    time_data=[-25, 60])
#
# # ILAE-1448 电流数据幅值异常_任意单相触发检查_1A
# all_flow_ILAE_1448(ip, DB_NAME, v_arg_2v0_gao_bing, "ILAE-1448", current_1A_sql_config, channel_2v0_scene1,
#                    addr_2v0_scene1,
#                    no_group_2v0, algo_scene, [150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150],
#                    time_data=[-25, 60])
#
# # ILAE-1449 电流数据幅值异常_幅值调整触发&恢复_5A
# all_flow_ILAE_1449(ip, DB_NAME, v_arg_2v0_gao_bing, "ILAE-1449", current_5A_sql_config, channel_2v0_scene1,
#                    addr_2v0_scene1,
#                    no_group_2v0, algo_scene, [150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150],
#                    time_data=[-25, 80])
#
# # ILAE-1450 电流数据幅值异常_幅值调整触发&删除线路恢复_5A
# all_flow_ILAE_1450(ip, DB_NAME, v_arg_2v0_gao_bing, "ILAE-1450", current_5A_sql_config, channel_2v0_scene1,
#                    addr_2v0_scene1,
#                    no_group_2v0, algo_scene, [150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150],
#                    time_data=[-25, 60])
#
# # ILAE-1451 电流数据幅值异常_任意单相触发检查_5A
# all_flow_ILAE_1451(ip, DB_NAME, v_arg_2v0_gao_bing, "ILAE-1451", current_5A_sql_config, channel_2v0_scene1,
#                    addr_2v0_scene1,
#                    no_group_2v0, algo_scene, [150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150],
#                    time_data=[-25, 60])
